#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <sys/wait.h>

int main()
{
    pid_t  pid = fork();

    if(pid == 0) {
        printf("I am child, will die!\n");
        sleep(2);
    } else if(pid > 0) {
        printf("I am parent, wait for child die!\n");
        pid_t wpaid = wait(NULL);

        printf("wait ok, wpaid = %d, pid = %d\n", wpaid, pid);

        while(1) {
            sleep(1);
        }
    }


    return 0;
}

